home *** CD-ROM | disk | FTP | other *** search
- Path: immuno.bme.nwu.edu!johnson
- From: johnson@immuno.bme.nwu.edu (George Johnson)
- Newsgroups: comp.lang.c
- Subject: Running out of memory with mmap
- Date: 6 Mar 1996 01:38:00 GMT
- Organization: Northwestern University, Evanston, IL, US
- Message-ID: <4hiq9o$h18@news.acns.nwu.edu>
- NNTP-Posting-Host: immuno.bme.nwu.edu
- Keywords: mmap
-
-
- Hi folks--
-
-
- I have this procedure which is called a few thousand times, each time
- with different requests for information from different large files.
- Within this procedure is :
-
- ....
-
- pa = mmap(0,fsiz,PROT_READ,MAP_PRIVATE,fpB,0);
-
- madvise(pa,fsiz,MADV_RANDOM);
-
- if ( pa == (caddr_t) -1) {
- perror("mmap failed");
- exit(1);
- }
-
- .... go to the specified offset in the file, grab the info
-
- .... leave procedure
-
- The size of the file(s) fpB are around 20 MB a piece. What happens
- is that after 100 or so calls, the program exits saying it has run
- out of memory.
-
- My question is where did the memory go? I don't understand what is
- going on. I free all malloc'ed stuff, there is little else going on
- in the program other than opening these big files, reading through
- them and grabbing out little pieces of information.
-
- My assumption (hehehe) from reading the manual page for mmap and
- munmap is that when mmap is called, it unmaps implicitly anybody
- occupying space 0 to fsiz, so no munmap is needed to free up (?)
-
- I'm not sure what I'm forgetting to do.
-
- Any suggestions would be very helpful.
-
- Thank you,
-
- George Johnson
- Kabat Database
-